package com.example.demo.efficiency;

import cn.hutool.core.util.RandomUtil;

import java.util.Date;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @author luojm
 * @describe
 * @datetime 2018/7/12 15:16
 */
public class Common {

    static ThreadLocalRandom random = RandomUtil.getRandom();

    public static String getString(Integer length) {
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < length; i++) {
            char c = (char) (random.nextInt(10000) + 20000);
            stringBuffer.append(c);
        }
        return stringBuffer.toString();
    }


    public static Date getDate() {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer = stringBuffer.append(1);
        for (int i = 0; i < 12; i++) {
            int c = random.nextInt(10);
            stringBuffer.append(c);
        }
        Long integer = Long.valueOf(stringBuffer.toString());
        Date date = new Date(integer);
        return date;
    }

    public static Integer getInteger(Integer integer) {
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < integer; i++) {
            int c = random.nextInt(10);
            stringBuffer.append(c);
        }
        return Integer.parseInt(stringBuffer.toString());
    }
}
